import {Model} from './model.js';
var model=new Model();
Page({

  /**
   * 页面的初始数据
   */
  data: {
      current: 1,
      current_scroll: 1,
      item_current: 0,
      interval: 2000,
      duration: 500,
      coupon_list: ''
  },
  onShow:function(){
    this.getUserCoupon()
  },

  // head_tab 切换
  handleChange: function (e) {
    var head_tab_curr = parseInt(e.detail.key) - 1;
    this.setData({ item_current: head_tab_curr })
  },

  // 切换tab
  switchTab: function (e) {
    var tab_curr = e.detail.current;
    this.setData({ current: tab_curr + 1 });
  },

  // 获取我的优惠券
  getUserCoupon:function(){
    model.getUserCoupon((res)=>{
      this.coupon_list = res.data
      this.setData({ coupon_list: res.data })
    })
  },

  // 去使用我的优惠券
  goUse(e){
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/coupon/mydetail?id='+id,
    })
  }
})